<?php

include _ITSTOCK_INCLUDE_DIR_.'html_options.inc.php';
include _ITSTOCK_INCLUDE_DIR_.'html_form.inc.php';

itstock_structure($structure, 'warehouse');
$edit = false;

if(isset($_POST['id'])){
  $structure['where'][0] = sprintf("`%s`.`id`='%s'", $structure['table'], itstock_decode($_POST['id']));
  $edit = itstock_search_all($structure);
}

echo '<b>'.(!$edit?'New ':'').'Warehouse</b><br><br><br><p class="error" id="e_msg" style="display: none;"></p>';
itstock_html_form_open($structure['type'], ($edit?itstock_encode($structure['data'][0]['id']):''));
?>
<tr>
  <td><label>Building:</label></td>
  <td><select id="building_id" name="building_id" required autofocus ><?php
    itstock_html_options('building', 'building', 'building_id', $structure, $edit);
  ?></select>
  </td>
</tr>
<?php
itstock_html_form_input_text('Warehouse Name:', 'warehouse' ,($edit?$structure['data'][0]['warehouse']:''), '(Optional)');
itstock_html_form_input_text('Floor #:', 'floor' ,($edit?$structure['data'][0]['floor']:''), 'Floor #', 'required');
?>
  <tr>
    <td><label onclick="HS('textarea_warehouse');" title="Click to show/hide">Comments:</label></td>
    <td><textarea <?php echo ($edit && $structure['data'][0]['comments'] !== ""? '':'style="display: none;"');?> form="form_warehouse" id="textarea_warehouse" name="warecomments"><?php echo ($edit?$structure['data'][0]['warecomments']:'')?></textarea></td>
  </tr>
<?php
itstock_html_form_close();
?>
